<template>
  <div>
    <!-- 基本信息 -->
    <jn-prj-detail :prj-id="urlParams.prjId" />
    <!-- 站址信息 -->
    <jn-site-detail v-if="[14].includes(+secondaryType)" :prj-id="urlParams.prjId" />
    <!-- 专享信息 -->
    <jn-proprietary-detail :prj-id="urlParams.prjId" :secondary-type="secondaryType" />
    <TCollapse title="结算订单信息">
      <Information ref="Information" :select-list="selectList" :form.sync="detailData" />
    </TCollapse>
    <!-- 附件  -->
    <zr-attach-list :prj-id="urlParams.prjId" />
    <Commitment ref="Commitment" :select-list="selectList" :form.sync="detailData" />
  </div>
</template>

<script>
import Information from './Information'
import Commitment from './commitment'
import { parseParams } from '@/utils'
// import * as Common from '@/api/common'
// import * as Axios from '@/api/settlement'
import JnPrjDetail from '@/components/jn/JnPrjDetail.vue'
import JnSiteDetail from '@/components/jn/JnSiteDetail.vue'
import JnProprietaryDetail from '@/components/jn/JnProprietaryDetail.vue'
import ZrAttachList from '@/components/zr/ZrAttachList.vue'
import TCollapse from '@/components/basic/TCollapse.vue'
import store from '@/store'

export default {
  name: 'SubmitApproval',
  components: {
    TCollapse,
    ZrAttachList,
    JnProprietaryDetail,
    JnSiteDetail,
    JnPrjDetail,
    Commitment,
    Information
  },
  data() {
    return {
      secondaryType: '',
      activeNames: [],
      collapseList: [
        { iframe: true, title: '项目基础详情', components: 'basicInfo', url: null },
        { iframe: true, title: '项目站址信息', components: 'siteInfo', url: null },
        { iframe: true, title: '项目专属信息', components: 'exclusive', url: null },
        { title: '结算订单信息', components: 'Information' },
        { iframe: true, title: '附件信息', components: 'AttachmentInfo', url: null, key: 'file' },
        { components: 'Commitment' }
      ],
      childData: {},
      selectList: {},
      detailData: {},
      // 父级传递相关数据
      parentForm: {},
      urlParams: {
        nodeNameWord: '',
        prjId: '',
        adjustId: '',
        activityId: '',
        workItemId: '',
        procInstId: '',
        taskId: '',
        taskType: 'todo',
        activityInstName: '',
        bizSeq: '20000'
      },
      junNanUrl: process.env.VUE_APP_JUNNAN_IFRAME_URL,
      fileUrl: process.env.VUE_APP_ZHONGRUAN_URL,
      iframeParams: {}
      // src: window.location.origin + '/#/materials',
      // refs1: null,
      // iframeHeight: 0
    }
  }
  // async created() {
  //   this.urlParams = {
  //     ...this.urlParams,
  //     ...parseParams(window.location.hash)
  //   }
  //   console.log('%c%s', 'color:#07CC9E;font-size:18px', '🌵：url跳转传参')
  //   console.log(this.urlParams, '============>')
  //   const { data } = await Axios.getPrjDetail({ prjId: this.urlParams.prjId })
  //   this.secondaryType = data.secondaryType
  //   store.commit('settings/setPageTitle', data?.prjName)
  //   let nodeId = 'JS_SS_NODE'
  //   if (+this.urlParams.isPush === 1) {
  //     nodeId = 'TS_CB_NODE'
  //   }
  //   this.iframeParams = {
  //     prjId: this.urlParams.prjId,
  //       prjType: data.prjType,
  //       nodeId,
  //       buildModes: data.buildModes,
  //       towerType: data.towerType,
  //       roomType: data.roomType
  //     }
  //   // const { data } = await Axios.getWFWorkItem({ workItemId: this.urlParams.workItemId })
  //   // console.log(data, '=====>workItemId获取到的值')
  //   // window.addEventListener('message', (e) => {
  //   //   const data = e.data
  //   //   if (data.state && data.state === 200) {
  //   //     this.workflowMessageCbAdded = false
  //   //   }
  //   // })
  // },
  // mounted() {
  //   this.ifarmSrcPram()
  //   this.collapseList.map(item => {
  //     if (!item.iframe) {
  //       this.childData[item.components] = this.$refs[item.components][0].$data
  //     }
  //   })

  //   window.addEventListener('message', (event) => {
  //     if (event.data.type === 'basicInfo') {
  //       // this.basicInfo = JSON.parse(event.data.data)
  //       // console.log('基本信息')
  //     }
  //     if (event.data.type === 'proprietaryInfo') {
  //       // console.log('专属信息')
  //     }
  //     if (event.data.type === 'siteInfo') {
  //       // this.siteInfo = JSON.parse(event.data.data)
  //       // console.log('站址信息')
  //     }
  //     if (event.data.type === 'attachment') {
  //       // this.$refs.myIframeFjRef.style.height = event.data.height + 'px'
  //       // console.log('附件高度')
  //     }
  //   })

  //   this.activeNames = this.collapseList.map(item => item.components)
  //   this.getSelectData()
  // },
  // methods: {
  //   getList() {
  //     this.$refs['Commitment'][0].handleForm(this.detailData)
  //     this.$refs['Information'][0].getList()
  //   },
  //   // 获取下拉框数据
  //   async getSelectData() {
  //     const arr = ['PROJ_TYPE', 'SECONDARY_TYPE', 'BUILD_MODES', 'PURCHASE_METHOD']
  //     for (const i in arr) {
  //       const res = await Common.getDropdownData(arr[i])
  //       this.$set(this.selectList, arr[i], res.data)
  //     }
  //   },
  //   // ifarm src 传参
  //   async ifarmSrcPram() {
  //     // const queryFinalSent = await Axios.queryFinalSent({ prjId: this.urlList.prjId }) // 目前写死 接口 等待老板确认
  //     // if (queryFinalSent.code === '200') {
  //     //   this.lcList = queryFinalSent.data // 获取流程参数
  //     // }
  //     // 基本信息
  //     this.collapseList.find(item => {
  //       return item.components === 'basicInfo'
  //     }).url = `${this.junNanUrl}design/basicInfo?prjId=${this.urlParams.prjId}`
  //     // 站址信息
  //     this.collapseList.find(item => {
  //       return item.components === 'siteInfo'
  //     }).url = `${this.junNanUrl}design/siteInfo?prjId=${this.urlParams.prjId}`
  //     //  专属信息
  //     this.collapseList.find(item => {
  //       return item.components === 'exclusive'
  //     }).url = `${this.junNanUrl}design/proprietaryInfo?prjId=${this.urlParams.prjId}`
  //     console.log(this.collapseList, '====>123')
  //     // console.log(this.lcList, '00000000000000000000')
  //     // 附件信息
  //     this.collapseList.find(item => {
  //       return item.components === 'AttachmentInfo'
  //     }).url = `${this.fileUrl}attachDetailList?prjId=${this.urlParams.prjId}`
  //     // console.log(this.fuJianSrc, ' this.fuJianSrc')
  //     // 审批信息
  //     this.collapseList.find(item => {
  //       return item.components === 'ApprovalList'
  //     }).url = `${this.junNanUrl}workflow/taskDetail/handleOnlyRecord?prjId=${this.urlParams.prjId}&processInstID=100000012355`
  //   },
  //   handleClose() {
  //     this.$emit('handleClose')
  //   }
  // }
}
</script>
<style scoped>
.el-collapse {
    margin-bottom: 15px;
    border: 1px solid #EBEEF5;
}
iframe.hide-scrollbar {
  overflow: hidden;
}
</style>
